package cn.tedu.core_banking.service;


import cn.tedu.core_banking.mapper.CustomerMapper;
import cn.tedu.core_banking.pojo.dto.AddCustomer;
import cn.tedu.core_banking.pojo.entity.Customer;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

@Service
@Slf4j
public class CustoemrService {
    @Autowired
    private CustomerMapper customerMapper;

    public List<Customer> insertCustomer( AddCustomer addCustomer){
        log.debug("addCustomer:"+addCustomer);
        Customer customer = new Customer();
        BeanUtils.copyProperties(addCustomer, customer);
        customer.setCreatedAt(new Date());
        int i= customerMapper.insertCustomer(customer);
        log.debug("影响条数:"+i);
        List<Customer> customer1 = customerMapper.selectCustomer(addCustomer.getName());
        return customer1;
    }

    public List<Customer> customerList (){
        List<Customer> customerList=customerMapper.customerList();
        return customerList;
    }
}
